package com.saishi.servlet;

import com.saishi.dao.UserDao;
import com.saishi.dao.impl.UserDaoImpl;
import com.saishi.entity.User;
import lombok.SneakyThrows;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/up")
public class UPdateServlet extends HttpServlet {
     UserDao dao = new UserDaoImpl();
    @SneakyThrows
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String sno = request.getParameter("sno");
        System.out.println(sno);
        int uid = Integer.parseInt(sno);
        User user = dao.myup(uid);
        System.out.println(user);
        request.setAttribute("updateuser",user);
        request.getRequestDispatcher("/updatexs.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
